// 在线面试平台。将链接分享给你的朋友以加入相同的房间。
// Author: tdzl2003<dengyun@meideng.net>
import java.util.*;

public class a21 {
    public  static  void  main(String[] args){
        Scanner in = new Scanner(System.in);
        int size = in.nextInt();
        int[] ar = new int[size];
        for(int i = 0;i<size;i++){
            ar[i] = in.nextInt();
        }
        int[] copyarr  = Arrays.copyOf(ar,size);
        Arrays.sort(copyarr);
        boolean[] haspositon = new boolean[size];
        int k = in.nextInt();
        for(int i=0;i<k;i++){
            int tem1 =in.nextInt()-1;
            int tem2 = in.nextInt()-1;
          if(tem1<size&&tem2<size){
            haspositon[tem1] = true;
          
            haspositon[tem2] =true;
          }
        }
        int a  = 0;

        List<Integer> list=  new LinkedList<>();
        for(int i =0;i<size;i++){
            if(copyarr[i]!=ar[i]&&haspositon[i]==false){
               list.add(i);
            }
        }
        while(!list.isEmpty()){
            int pos =list.get(0);
            Set<Integer> set = new HashSet<>();
            while(true){
                if(haspositon[pos]){
                    break;
                }
                if(set.contains(pos)){
                    a--;
                    break;
                }
                set.add(pos);
                pos = ar[pos]-copyarr[0];
                a++;

            }
            for(Integer tem:set){
                list.remove(tem);
              haspositon[tem] = true;
            }
          set.clear();
        }

        if(a==0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
            System.out.println(a);
        }
    }
}
